let data=[10,60,20,3,40,56,7];
console.log("排序前:"+data);
for(var i=0;i<data.length;i++){
    for(var j=0;j<data.length-1;j++){
        if(data[j]>data[j+1]){
            var temp=data[j];
            data[j]=data[j+1];
            data[j+1]=temp;
        }
    }

}
console.log("排序后"+data);

console.log()
let arr = [10,60,20,3,40,56,7];

console.log('排序前：', arr);
shuzu(arr);
console.log('排序后：', arr)
function shuzu(arr) {
    for (let i = 1; i < arr.length; i++) {
        let one = arr[i];
        let data = i - 1;
        while (data >= 0 && one < arr[data]) {
            arr[data + 1] = arr[data];
            data--;
        }
        if (data + 1 !== i) {
            arr[data + 1] = one;
        }

    }
}